package com.normal.practise.controller;


import com.normal.practise.entity.DataHero;
import com.normal.practise.entity.DataUser;
import com.normal.practise.entity.result.DataHeroReturn;
import com.normal.practise.response.ResponseResult;
import com.normal.practise.service.DataHeroService;
import com.normal.practise.service.DataUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author SiYaoLee
 * @since 2021-05-12
 */
@Api(value = "英雄数据")
@RestController
@RequestMapping("/practise/data-hero")
public class DataHeroController {
    @Autowired
    private DataHeroService dataHeroService;

    @ApiOperation("查询所有英雄数据")
    @GetMapping("findAll_hero")
    public ResponseResult findAll() {
        List<DataHero> list = dataHeroService.list(null);
        ArrayList<DataHeroReturn> returnList = new ArrayList<>();
        for (DataHero dataHero : list){
            DataHeroReturn dataHeroReturn = new DataHeroReturn();
            dataHeroReturn.setName(dataHero.getHeroName());
            dataHeroReturn.setKda(dataHero.getHeroKda());
            returnList.add(dataHeroReturn);
        }
        return ResponseResult.successResult(returnList);
    }
}

